<?php

namespace app\dao\report;

use app\dao\BaseDao;
use app\model\report\Report;

class ReportDao extends BaseDao
{
    protected function setModel(): string
    {
        return Report::class;
    }

    /**
     * 获取统计列表
     * @param array $where
     * @param string $field
     * @param int $page
     * @param int $limit
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getList(array $where, string $field = '*', int $page = 1, int $limit = 10): array
    {
        return $this->getModel()->where($where)->field($field)->order('day DESC')->page($page, $limit)->select()->toArray();
    }

    public function getCount(array $where)
    {
        return $this->getModel()->where($where)->count();
    }

}